package com.blogspot.dizpers.scribendi.plugins.plugincontainer;

import java.util.List;
import java.util.Map;

import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;

import com.blogspot.dizpers.scribendi.plugins.api.IPlugin;
import com.blogspot.dizpers.scribendi.plugins.api.IPluginContext;

public class PluginContainer implements IPluginContainer {

	private final Map<String, IPluginContext> contexts;

	@Inject
	public PluginContainer(Map<String, IPluginContext> contexts) {
		this.contexts = contexts;
	}

	public void run(String sPlugin) {
		IPluginContext context = contexts.get(sPlugin);
		Injector pluginjector = Guice.createInjector(context.getModule());
		IPlugin plugin = pluginjector.getInstance(IPlugin.class);
		plugin.invoke();
	}
}